<template>
    <div>
        <el-row>
            <el-col :span="8">
                <!-- 头像卡片 -->
                <el-card class="box-card">
                    <div class="user">
                        <img src="" alt="头像">
                        <div class="user-info">
                            <p class="name">Admin</p>
                            <p class="access">超级管理员</p>
                        </div>
                    </div>
                    <div class="login-info">
                        <p>邮箱：<span>2023/2/9</span></p>
                        <p>号码：<span>天堂</span></p>
                    </div>
                </el-card>
                <!-- 表格展示 -->
                <el-card style="margin-top: 20px;height: 460px;">
                    <template>
                        <el-table :data="tableData" style="width: 100%">
                            <el-table-column :prop="key" :label="val" v-for="(val, key) in tableLabel" :key="key" />
                        </el-table>
                    </template>
                </el-card>
            </el-col>
            <el-col :span="16">
            </el-col>
            <el-col :span="16" style="padding-left:10px">
                <!-- 小卡片展示 -->
                <div class="num">
                    <el-card v-for="item in countData" :key="item.name" :body-style="{ display: 'flex', padding: 0 }">
                        <i class="icon" :class="`el-icon-${item.icon}`" :style="{ background: item.color }"></i>
                        <div class="detail">
                            <p class="price">{{ item.value }}</p>
                            <p class="desc">{{ item.name }}</p>
                        </div>
                    </el-card>
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script>
export default {
    name: 'Dashboard',
    data() {
        return {
            // 表格数据
            tableData: [],
            // 表格标签（用于遍历）
            tableLabel: {
                name: '文章',
                todayBuy: '今日发布',
                monthBuy: '月发布',
                totalBuy: '总发布'
            },
            // 小卡片数据
            countData: [
                {
                    name: '文章',
                    value: 12,
                    icon: 'success',
                    color: '#2ec7c9'
                },
                {
                    name: '标签',
                    value: 2,
                    icon: 'star-on',
                    color: '#ffb980'
                },
                {
                    name: '分类',
                    value: 14,
                    icon: 's-goods',
                    color: '#5ab1ef'
                },
                {
                    name: '访问量',
                    value: 14,
                    icon: 'success',
                    color: '#2ec7c9'
                }
            ],
            // 饼图
            videoData: [
                {
                    name: '小米',
                    value: 2999
                },
                {
                    name: '苹果',
                    value: 5999
                },
                {
                    name: 'vivo',
                    value: 1500
                },
                {
                    name: 'oppo',
                    value: 1999
                },
                {
                    name: '魅族',
                    value: 2200
                },
                {
                    name: '三星',
                    value: 4500
                }
            ]
        }
    }

}
</script>

<style scoped lang="less">
/* 头像卡片 */
.box-card {
    .user {
        display: flex;
        align-items: center;
        padding-bottom: 20px;
        margin-bottom: 20px;
        border-bottom: 1px solid #ccc;

        img {
            margin-right: 40px;
            width: 150px;
            height: 150px;
            border-radius: 50%;
        }

        .user-info {
            .name {
                font-size: 32px;
                margin-bottom: 10px;
            }

            .access {
                color: #999
            }
        }
    }

    .login-info {
        p {
            line-height: 28px;
            font-size: 14px;
            color: #999;

            span {
                margin-left: 60px;
                color: #666;
            }
        }
    }
}

/* 小卡片展示 */
.num {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;

    .el-card {
        width: 32%;
        margin-bottom: 20px;
    }

    /* 图标 */

    .icon {
        width: 80px;
        height: 80px;
        line-height: 80px;
        text-align: center;
        font-size: 30px;
        color: #fff;
    }

    /* 图标旁边的文字 */

    .detail {
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-left: 15px;

        .price {
            font-size: 30px;
            margin-bottom: 10px;
            line-height: 30px;
        }

        .desc {
            font-size: 14px;
            color: #999;
        }

    }
}

/* 柱状图、饼图 */
.graph {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-top: 20px;

    .el-card {
        width: 48%;
    }
}
</style>